// pages/my/unblockedapply/unblockedapply.js
Page({

  data: {
    userInfo: {},
    message: "",
    fileList: [],
    imgIds: []
  },
  onLoad: function (options) {
    getApp().globalData.http.userInfo().then(res => {
      this.setData({
        userInfo: res.data
      });
    });
  },
  submit() {
    if (!this.data.message) {
      getApp().globalData.vant.toast("申诉内容不能为空");
    } else {
      getApp().globalData.http.accountUnlock({
        applayContent: this.data.message,
        applayImg: this.data.imgIds.join(",")
      }).then(res => {
        getApp().globalData.vant.dialog.alert({
          title: "提交成功",
          message: "我们已收到您的申诉申请，3个工作日内给您回复结果。",
          confirmButtonText: "好的",
          confirmButtonColor: "#33B868"
        }).then(() => {
          wx.switchTab({
            url: "/pages/my/index/index",
          });
          getCurrentPages()[0].onLoad();
        });
      });
    }
  },
  upload(e) {
    getApp().globalData.util.imgsUpload(this, e, this.data.fileList, this.data.imgIds);
  },
  delete(e) {
    let i = e.detail.index;
    let fileList = this.data.fileList;
    let imgIds = this.data.imgIds;
    fileList.splice(i, 1);
    imgIds.splice(i, 1);
    this.setData({
      fileList: fileList,
      imgIds: imgIds
    });
  },
})